package org.kealinghornets.jchuah.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Toast;


public class MyActivity3 extends Activity {
    int numcleared = 0;

    public void onClockButtonPush(final View viewThatWasPushed) {

        Log.d("org.kealinghornets.jchuah.myapplication" , "clock pushed");

        Toast.makeText(this , "clock pushed" , Toast.LENGTH_LONG);

        startActivity(new Intent(this , MyActivity.class));
    }

    public void Onclockbuttonpush(final View view){
        Animation fade_out_animation = AnimationUtils.loadAnimation(this , R.anim.fade_out);
        fade_out_animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                view.setEnabled(false);

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.setEnabled(true);
                view.setAlpha(0);
                view.clearAnimation();

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

        });
        if (view.getAlpha() == 1) {
            view.startAnimation(fade_out_animation);
            numcleared = numcleared + 1;

        } else {
            view.setAlpha(1);
            numcleared = numcleared - 1;
        }

        if (numcleared == 5){
            startActivity(new Intent(this , MyActivity2.class));
        }


    }



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_activity3);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my_activity3, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
